From f89c5d1f1c028b6a6006aff1a3809fafe80d0aa1 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 8 Nov 2007 10:33:18 +0000 Subject: [PATCH] x86, hvm: Clean up periodic timer code a little. This leads naturally to a no-missed-tick-accounting mode which is a combination of ticks delivered 'off beat' immediately upon re-scheduling when ticks are missed, then reverting to delivering ticks 'on beat' as usual. Signed-off-by: Keir Fraser --- xen/arch/x86/hvm/vpt.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 7199fdf674..9f691cae0c 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -56,17 +56,9 @@ static void pt_process_missed_ticks(struct periodic_time *pt) if ( missed_ticks <= 0 ) return; - if ( mode_is(pt->vcpu->domain, no_missed_tick_accounting) ) - { - pt->pending_intr_nr = 1; - pt->scheduled = now + pt->period; - } - else - { - missed_ticks = missed_ticks / (s_time_t) pt->period + 1; - pt->pending_intr_nr += missed_ticks; - pt->scheduled += missed_ticks * pt->period; - } + missed_ticks = missed_ticks / (s_time_t) pt->period + 1; + pt->pending_intr_nr += missed_ticks; + pt->scheduled += missed_ticks * pt->period; } static void pt_freeze_time(struct vcpu *v) @@ -131,10 +123,7 @@ static void pt_timer_fn(void *data) pt_lock(pt); - if ( mode_is(pt->vcpu->domain, no_missed_tick_accounting) ) - pt->pending_intr_nr = 1; - else - pt->pending_intr_nr++; + pt->pending_intr_nr++; if ( !pt->one_shot ) { @@ -235,11 +224,16 @@ void pt_intr_post(struct vcpu *v, struct hvm_intack intack) } else { - pt->pending_intr_nr--; if ( mode_is(v->domain, no_missed_tick_accounting) ) + { pt->last_plt_gtime = hvm_get_guest_time(v); + pt->pending_intr_nr = 0; /* 'collapse' all missed ticks */ + } else + { pt->last_plt_gtime += pt->period_cycles; + pt->pending_intr_nr--; + } } if ( mode_is(v->domain, delay_for_missed_ticks) && -- 2.30.2